import Vue from 'vue'
import App from './App'
import { $http } from "@escook/request-miniprogram"
// 1.导入store实例对象
import store from './store/store.js'

uni.$http = $http
//请求的根路径
$http.baseUrl = 'https://api-ugo-web.itheima.net'

$http.beforeRequest = function(options){
  uni.showLoading({
    title:"数据加载中..."
  })
  // console.log(options)
  // if(options.url.indexOf('/my') !== -1){
    options.header ={
      Authorization: store.state.m_user.token
    }
  // }
}
$http.afterRequest = function(options){
  uni.hideLoading()
}

uni.$showMessage = function(title='数据加载失败!', duration=1500){
  uni.showToast({
    title,
    duration,
    icon:'none'
  })
  
}

Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
	...App,
    // 2. 将 store 挂载到 Vue 实例上
   store
})
app.$mount()
